<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Controller extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->settings->load('site');
        $this->_get_web_status();
        $this->load->model('home_model','home');
    }
   //error函数
    protected function error($msg = ':(  出错了！',$url = '',$time = 1)
    {
        $url = $url ? "window.location.href='" . site_url($url) . "'" : "window.location.href='".DX_HISTORY."'";
        $this->load->view('common/error',array('msg' => $msg, 'url' => $url, 'time' => $time));
        echo $this->output->get_output();
        exit();
    }
    //success函数
    protected function success($msg = ':)  操作成功',$url = '',$time = 1)
    {
        $url = $url ? "window.location.href='" . site_url($url) . "'" : "window.location.href='".DX_HISTORY."'";
        $this->load->view('common/success',array('msg' => $msg, 'url' => $url, 'time' => $time));
        echo $this->output->get_output();
        exit();
    }

    //网站设置为0的时候，不能访问
    private function _get_web_status()
    {
        $data = $this->settings->item('setting');
        if($data['status'] == 1)
        {
            return true;
        }
        else
        {
            header("Content-type: text/html; charset=utf-8");
            p($data['close_reason']);
        }
    }
}